import {Component, OnInit} from '@angular/core';
import {Product, ProductService} from '../product.service';
import {FormControl} from '@angular/forms';

import 'rxjs/add/operator/debounceTime';

@Component({
  selector: 'app-product',
  templateUrl: './product.component.html',
  styleUrls: ['./product.component.css']
})
export class ProductComponent implements OnInit {
  private products: Product[];

  constructor(private productService: ProductService) {
    this.titleFilter.valueChanges
      .debounceTime(500).subscribe(value => this.keyword = value);
  }

  private keyword = '';
  private titleFilter = new FormControl();

  ngOnInit() {
    this.products = this.productService.getProducts();

  }


}
